package com.chen.schedule.dao.impl;

import com.chen.schedule.dao.BaseDao;
import com.chen.schedule.dao.SysUserDao;
import com.chen.schedule.pojo.SysUser;

import java.util.List;

public class SysUserDaoImpl extends BaseDao implements SysUserDao {
    @Override
    public Integer save(SysUser user) {
        // 向数据库中插入一条记录
        String sql = "insert into sys_user (username, user_pwd) values  (?,?)";
        // BaseDao 在对异常进行处理，一旦有异常，就会返回一个 0 值
        return baseUpdate(sql, user.getUsername(), user.getUserPwd());
    }


    @Override
    public List<SysUser> queryByUsername(String username) {
        String sql = "select uid, username, user_pwd userPwd from sys_user where username = ?";
        return baseQuery(SysUser.class, sql, username);
    }
}
